package com.hbmcc.rxjava.base

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.hbmcc.rxjava.databinding.ChapterItemBinding

/**
 * 创建日期：2020/11/2
 * 描述:章节的列表
 * 作者:支豪亮
 */
class ChapterAdapter(
    private val mList: List<InfoBean>,
    private val mIInfoCallback: IInfoCallback
) : RecyclerView.Adapter<ChapterAdapter.ChapterViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChapterViewHolder {
        val binding = ChapterItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return ChapterViewHolder(binding)
    }

    override fun onBindViewHolder(holder: ChapterViewHolder, position: Int) {
        holder.binding.infoBean = mList[position]
        holder.binding.infoCallback = mIInfoCallback
    }

    override fun getItemCount(): Int {
        return mList.size
    }


    class ChapterViewHolder(val binding: ChapterItemBinding) : RecyclerView.ViewHolder(binding.root)
}